package com.puboot.module.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.puboot.common.util.CoreConst;
import com.puboot.module.admin.mapper.BizBannerMapper;
import com.puboot.module.admin.model.BizBanner;
import com.puboot.module.admin.service.BizBannerService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * @Description
 * @Author 申紫微
 * @Data 2020-03-14 11:21:23
 * @Version 1.0
 */
@Service
@AllArgsConstructor
public class BizBannerServiceImpl extends ServiceImpl<BizBannerMapper,BizBanner> implements BizBannerService {

    private final BizBannerMapper bannerMapper;

    @Override
    public boolean save(BizBanner banner) {
        Date date = new Date();
        banner.setCreateTime(date);
        banner.setStatus(CoreConst.STATUS_VALID);
        int i = bannerMapper.insert(banner);
        if( i > 0  ){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteBanner(Integer id) {
        BizBanner banner = bannerMapper.selectById(id);
        banner.setStatus(CoreConst.STATUS_INVALID);
        int i = bannerMapper.updateById(banner);
        return i > 0;
    }

    @Override
    @Transactional
    public boolean batchDelete(Integer[] ids) {
        int i = bannerMapper.deleteBatchIds(ids);
        if(i == ids.length){
            return true;
        }
        return false;
    }

    @Override
    public List<BizBanner> pageBanner(IPage<BizBanner> page, BizBanner banner) {
        List<BizBanner> bizBanners = bannerMapper.selectPageBanner(page, banner);
        return bizBanners;
    }

    @Override
    public BizBanner selectById(Integer id) {
        return bannerMapper.selectById(id);
    }

    @Override
    public List<BizBanner> selectAllBanner() {
        List<BizBanner> bizBanners = bannerMapper.selectAllBanner();
        return bizBanners;
    }

    @Override
    public boolean saveBatch(Collection<BizBanner> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdateBatch(Collection<BizBanner> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean removeById(Serializable id) {
        return false;
    }

    @Override
    public boolean removeByMap(Map<String, Object> columnMap) {
        return false;
    }

    @Override
    public boolean remove(Wrapper<BizBanner> queryWrapper) {
        return false;
    }

    @Override
    public boolean removeByIds(Collection<? extends Serializable> idList) {
        return false;
    }

    @Override
    public boolean updateById(BizBanner entity) {
        return false;
    }

    @Override
    public boolean update(BizBanner entity, Wrapper<BizBanner> updateWrapper) {
        return false;
    }

    @Override
    public boolean updateBatchById(Collection<BizBanner> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdate(BizBanner entity) {
        return false;
    }

    @Override
    public BizBanner getById(Serializable id) {
        return null;
    }

    @Override
    public Collection<BizBanner> listByIds(Collection<? extends Serializable> idList) {
        return null;
    }

    @Override
    public Collection<BizBanner> listByMap(Map<String, Object> columnMap) {
        return null;
    }

    @Override
    public BizBanner getOne(Wrapper<BizBanner> queryWrapper, boolean throwEx) {
        return null;
    }

    @Override
    public Map<String, Object> getMap(Wrapper<BizBanner> queryWrapper) {
        return null;
    }

    @Override
    public <V> V getObj(Wrapper<BizBanner> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }

    @Override
    public int count(Wrapper<BizBanner> queryWrapper) {
        return 0;
    }

    @Override
    public List<BizBanner> list(Wrapper<BizBanner> queryWrapper) {
        return null;
    }

    @Override
    public IPage<BizBanner> page(IPage<BizBanner> page, Wrapper<BizBanner> queryWrapper) {
        return null;
    }

    @Override
    public List<Map<String, Object>> listMaps(Wrapper<BizBanner> queryWrapper) {
        return null;
    }

    @Override
    public <V> List<V> listObjs(Wrapper<BizBanner> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }

    @Override
    public IPage<Map<String, Object>> pageMaps(IPage<BizBanner> page, Wrapper<BizBanner> queryWrapper) {
        return null;
    }

}
